<!DOCTYPE html>
<html>

<head>
  <title>注册-问答首页</title>
  <meta charset="utf-8">
  <meta name="Keywords " content="$SiteKeywords " />
  <meta name="Description " content="$SiteDescription " />
  <link rel="stylesheet " type="text/css " href="css/bootstrap.min.css" />
  <link rel="stylesheet " type="text/css " href="css/globle.css " />
  <link rel="stylesheet " type="text/css " href="css/popupInsert.css" />
  <link rel="stylesheet " type="text/css " href="css/style.css " />
  <script src='js/jquery-2.0.3.js'></script>
  <script src='js/popupInsert.js'></script>
  <script src='js/index.js'></script>
  <script type="text/javascript">
  $(function() {
    // 拦截form表单的提交事件
    $("form").submit(function(ev) {
      //阻止默认事件
      ev.preventDefault();
      // 可以把表单里的所有内容都读出来形成一个字符串
      var data = $(this).serialize();
      // 把表单里的所有内容都读出来放在一个数组里
      // console.dir( $(this).serializeArray() );

      // ajax 发送请求
      $.post('user/register', data, function(res, statusText, xhr) {
        if (statusText == "success") {
          // console.log(res)
          if (res.code == "success") {
            $.popup(res.content, function() {
              location.href = "/login.html";
            })
          } else {
            $.popup(res.content);
          }

        }

      })

    });

  });
  </script>
</head>

<body>
  <div class="h50"></div>
  <div id="nav">
    <nav class="nav">
      <!-- 用户下拉 -->
      <div class="user-info" style="display: none">
        <a href="javascript:;">个人资料</a>
        <a href="javascript:;">退出</a>
      </div>
      <div class="back"><span class="glyphicon glyphicon-chevron-left"></span></div>
      <div class="title">注册</div>
      <div class="user"><span class="glyphicon glyphicon-home fs18"></span>
      </div>
    </nav>
  </div>
  <main>
    <div class="ask-content">
      <form action="/login" method="post">
        <div class="form-group">
          <input type="text" name="name" class="form-control" required pattern="^[0-9a-zA-Z\u4e00-\u9fa5]{2,16}$" placeholder="请输入昵称">
        </div>
        <div class="form-group">
          <input type="password" name="password" class="form-control" required pattern="^.{6,16}$" placeholder="请输入密码">
        </div>
        <div class="form-group">
          <input type="password" name="password01" class="form-control" required pattern="^.{6,16}$" placeholder="请再次输入密码">
        </div>
        <div class="form-group">
          <input type="radio" name="sex" value="女士">女士
          <br>
          <input type="radio" name="sex" value="先生">先生
        </div>
        <div class="form-group">
          <input type="text" name="email" class="form-control" required placeholder="请输入电子邮箱地址">
        </div>
        <div>
          <select name="course" class="form-control">
            <option value="HTML5">HTML5</option>
            <option value="IOS">IOS</option>
            <option value="Android">Android</option>
          </select>
          <br>
        </div>
        <input type="submit" class="btn btn-success form-control" value="注册" data-toggle="modal" data-target="#myModal">
      </form>
    </div>
  </main>
</body>

</html>
